import {useTagStore} from '@/store/App.js'
export const routerBefore=(router)=>{
  let noLoginPage=['/login'];//免登录页面
  router.beforeEach(async (to,from,next)=>{
    if(noLoginPage.includes(to.path)||to.path.includes('/redirect')){
      next()
      return
    }
    const tagStore=useTagStore();
    tagStore.addTag(to);
    to.meta.keep&&tagStore.addCache(to.name);
    next()
    return
  })
}

export const filterRoute = (data) => {
  data.forEach((item) => {
      if (item.children?.length > 0 && item.menu_type === 1) {
          delete item.component;
          filterRoute(item.children);
      }
  });
  return data;
};